// PaymentMapper.java
package com.registration.mapper;

import com.registration.bean.OrderBean;
import com.registration.bean.PatientBean;
import com.registration.bean.PaymentBean;
import com.registration.bean.UserBean;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface PaymentMapper {

    /**
     * 查询就诊人待缴费项目
     */
    List<PaymentBean> selectPendingPaymentItemsByUserId(@Param("patientId") Integer patientId,
                                                        @Param("statusList") Integer status);

    /**
     * 查询就诊人缴费记录
     */
    List<PaymentBean> selectPaymentRecordsByUserId(Integer patientId,@Param("statusList") List<Integer> statusList);

    /**
     * 插入缴费记录
     */
    int insertPaymentRecord(PaymentBean paymentBean);

    /**
     * 更新支付项目状态
     */
    int updatePaymentItemStatus(Integer record_id);

    /**
     * 根据订单ID获取待支付项目
     */
    List<PaymentBean> selectPendingItemsByOrderId(Integer orderId);

    /**
     * 根据交易号查询支付记录
     */
    PaymentBean selectPaymentByTradeNo(String tradeNo);

    /**
     * 申请退款，从数据库中删除支付记录
     */
    int applyRefund(PaymentBean paymentBean);



    /**
     * 查询指定时间前的待支付订单
     */
    List<PaymentBean> selectPendingPaymentsBeforeTime(LocalDateTime timeoutTime);

    /**
     * 更新支付记录状态，释放号源
     */
    int updatePaymentStatus(@Param("recordId") Integer recordId, @Param("status") Integer status);

}
